<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Random color example — event handler property</title>
    <style>
      button {
        margin: 10px;
      }
    </style>
  </head>
  <body>
    <button>Change color</button>
    <script>
      const btn = document.querySelector('button');

      function random(number) {
        return Math.floor(Math.random()*number);
      }

      function bgChange(e) {
        const rndCol = 'rgb(' + random(255) + ',' + random(255) + ',' + random(255) + ')';
        e.target.style.backgroundColor = rndCol;
        console(e)
      }

      btn.addEventListener('click',bgChange);
    </script>
  </body>
</html>